#ifndef __SELECT_MODEL_H__
#define __SELECT_MODEL_H__


#include<sys/time.h>
#include<sys/types.h>
#include<unistd.h>


#include "io_model.h"

//select的上下文
typedef struct select_ctx{
	int maxfd;
	fd_set readset;
	fd_set writeset;
	struct timeval tv;
}SELECT_CTX;



/*select的IO多路复用类
 *
 *
 */
class SelectMode:public ioModel{
	public:
		~SelectMode();
		SelectMode();
		int init();
		int addEvent(int fd);
		int addEvent(void *arg);
		int delEvent(void *arg);
		int waitForEvent();
		std::string & getIoName(){ return this->ioname; }
		void * getIoCtx() { return &ctx; }
	private:
		SELECT_CTX  ctx;
		std::string ioname;
		MemPool mem;
};


#endif 

